package com.kehutong.charge.dao;

import java.util.HashMap;
import java.util.List;
import org.coraframework.orm.annotation.Dao;
import org.coraframework.orm.annotation.Mapper;
import org.coraframework.orm.jdbc.Page;
import org.coraframework.orm.jdbc.execute.Condition;
import org.coraframework.orm.jdbc.execute.QueryCondition;
import com.kehutong.charge.vo.ChargeBillItemsVO;

@Dao
public interface ChargeArrearsDao {


	@Mapper(
			genericType = com.kehutong.charge.entity.ChargeBillItems.class,
			countSQL = "SELECT COUNT(1) FROM(SELECT id FROM t_charge_bill_items WHERE ${}) a",
			sql= "SELECT * FROM t_charge_bill_items WHERE ${}"
	)
	Page<com.kehutong.charge.entity.ChargeBillItems> arrearsItemCommunityPage(Condition... condition);


	@Mapper(
			genericType = ChargeBillItemsVO.class,
			countSQL = "SELECT COUNT(1) FROM(SELECT id FROM t_charge_bill_items WHERE ${}) a",
			sql= "SELECT communityNo,communityName,houseNo,buildNo,userNo,mobile,chargeName,'' avatar,residentsType,billAddress,COUNT(1) configNumberNO," +
					"houseBillNo,billYearMonth,billAmount,negotiateAmount,payableAmount,"+
					"IFNULL(SUM(payableAmount),0.00) amountTotal FROM t_charge_bill_items WHERE ${}"
	)
	Page<ChargeBillItemsVO> statistPage(Condition... condition);


	@Mapper(
			genericType = HashMap.class,
			countSQL = "SELECT COUNT(1) FROM(SELECT communityNo FROM t_charge_bill_items WHERE ${}) a",
			sql= "SELECT communityNo,communityName,houseNo,buildNo,userNo,mobile,chargeName,'' avatar,residentsType,billAddress,COUNT(1) configNumberNO," +
					"houseBillNo,billYearMonth,billAmount,negotiateAmount,payableAmount,"+
					"IFNULL(SUM(payableAmount),0.00) amountTotal FROM t_charge_bill_items WHERE ${}"
	)
	Page<ChargeBillItemsVO> findCommunityPage(Condition... condition);


	@Mapper(
			genericType = ChargeBillItemsVO.class,
			sql= "SELECT communityNo,communityName,houseNo,buildNo,userNo,mobile,chargeName,'' avatar,residentsType,billAddress,COUNT(1) configNumberNO," +
					"houseBillNo,billYearMonth,billAmount,negotiateAmount,payableAmount,"+
					"IFNULL(SUM(payableAmount),0.00) amountTotal FROM t_charge_bill_items WHERE ${}"
	)
	List<ChargeBillItemsVO> getArrearsByUserNo(QueryCondition find);
}
